﻿/**
 * 设置默认文字
 * @param id
 * @param defValue
 */
function defInputText(id, defValue) {
	var controlFile = $("#" + id);
	controlFile.val(defValue);
	controlFile.bind("focus", function() {
		if (defValue == controlFile.val()) {
			controlFile.val("");
		}
	});

	controlFile.bind("blur", function() {
		if (controlFile.val() == "") {
			controlFile.val(defValue);
		}
	});
}

/**
 * 格式化卡号
 * @param cardNo
 */
function bankCardNo(cardNo){
	 var obj = $("#"+cardNo);
	 obj.bind("keyup",function(){
	 	var val =obj.val().replace(/\D/g, '').replace(/\s/g,'').replace(/(\d{4})(?=\d)/g, "$1 ");
	 	obj.val(val);
	 });
}

/**
 * 设置字段隐藏
 * @param cardNo
 */
function repStrByLen(data,repStr,start,end)
{
	var str1 = data.substring(0,start);
	var str2 = data.substring(end-1,data.length);
	return str1+repStr+str2;
}

/**
 * 去除银行卡号中的空格
 * @param val
 * @returns
 */
function validateBankNo(val)
{
	val = val.replace(/[ ]/g,"");
	return /^\d{15,20}$/.test(val);
}

